Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: made a new password input component #108

Merged
merged 10 commits into from
Nov 1, 2023
Merged

feat: made a new password input component #108

merged 10 commits into from
Nov 1, 2023

Conversation

NasgulNexus
Copy link
Contributor

No description provided.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

TextInput,
TextInputProps,
} from '@gravity-ui/uikit';
import _ from 'lodash';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем тут lodash?

src/components/Password/Password.tsx Outdated Show resolved Hide resolved
src/components/Password/Password.tsx Outdated Show resolved Hide resolved
src/components/Password/Password.tsx Outdated Show resolved Hide resolved
src/components/Password/Password.tsx Outdated Show resolved Hide resolved
}

&__button {
--yc-button-background-color-hover: transparent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is not part of public API. Moreover this var will be removed in the next major

/** Show copy button */
showCopyButton?: boolean;
/** Show visibility button */
showVisibilityButton?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets call it showRevealButton

<div className={b('additional-right-content')}>
{rightContent}
{value && showCopyButton ? (
<CopyToClipboard text={String(value)} timeout={500}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced with ClipboardButton component, which have tooltip functionality

view="flat-secondary"
onClick={onClick}
className={b('button')}
size="s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use different sizes for each TextInput size

) : null}
{showVisibilityButton ? (
<Button
view="flat-secondary"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-label prop would be nice here with the texts: Show password/Hide password

type={hideValue ? 'password' : 'text'}
rightContent={additionalRightContent}
autoComplete={autoComplete ? autoComplete : 'new-password'}
className={b('input', className)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the input's className, you should pass it to the controlProps prop

/** Show reveal button */
showRevealButton?: boolean;
/** Disable tooltip. Tooltip won't be shown */
hasTooltip?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would pick separate names here, hasCopyTooltip and hasRevealTooltip

<ClipboardButton
text={value}
hasTooltip={hasTooltip}
size={16}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should map input size to button size

<Button
view="flat-secondary"
onClick={onClick}
size={size}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextInput size !== Button size, take a look at clear button, maybe reuse this logic here as well


return (
<TextInput
{...props}
type={hideValue ? 'password' : 'text'}
rightContent={additionalRightContent}
autoComplete={autoComplete ? autoComplete : 'new-password'}
className={b('input', className)}
controlProps={{
className: b(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it's an opposite, you're passing root className (b()) to the control node

return (
<div className={b()}>
<PasswordInput {...props} onUpdate={setValue} value={value} />
<Button onClick={generateRandomValue} className={b('button-generate-random-value')}>
Copy link

@personaljs personaljs Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add prop showCopyButton and showRevealButton?

@@ -86,7 +102,8 @@ export const PasswordInput: React.FC<PasswordInputProps> = (props) => {
rightContent={additionalRightContent}
autoComplete={autoComplete ? autoComplete : 'new-password'}
controlProps={{
className: b(),
className: b('input-control', controlProps?.className),
...controlProps,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spread should be before the className, otherwise it would be overwritten by the controlProps

@amje amje changed the title feat(Password): made a new input password feat: made a new password input component Oct 31, 2023
@NasgulNexus NasgulNexus merged commit 5b1c15d into main Nov 1, 2023
3 checks passed
@NasgulNexus NasgulNexus deleted the password branch November 1, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants